﻿using System;
using System.Web.UI.WebControls;
using BLL.RF.TestRecord;

public partial class ViewbyProduct_ViewOtherData_ViewCurrentCheck_ViewCurrentCheckbyDT : System.Web.UI.Page
{
    private Test_Record tr;
    private DateTime dt1
    {
        get { return DateTime.Parse(ViewState["dt1"].ToString()); }
        set { ViewState["dt1"] = value; }
    }
    private DateTime dt2
    {
        get { return DateTime.Parse(ViewState["dt2"].ToString()); }
        set { ViewState["dt2"] = value; }
    }

    public ViewbyProduct_ViewOtherData_ViewCurrentCheck_ViewCurrentCheckbyDT()
    {
        tr = new Test_Record();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        dt1 = DateTime.Parse(this.TextBox1.Value.Trim());
        dt2 = DateTime.Parse(this.TextBox2.Value.Trim());
        BindGV();
    }

    protected void BindGV()
    {
        this.GridView1.DataSource = tr.Test_Record_GetCurrentCheck_byDT(dt1, dt2);
        this.GridView1.DataBind();
    }

    protected void GridView1_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindGV();
    }

    protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if ((bool)GridView1.DataKeys[e.Row.RowIndex].Values[2] == true)
            {
                e.Row.Cells[8].Text = "Pass";
            }
            else
            {
                e.Row.Cells[8].Text = "Fail";
                e.Row.Cells[8].ForeColor = System.Drawing.Color.Red;
            }
        }
    }
}
